package cn.oa.service.impl;

import cn.oa.dao.PositionDao;
import cn.oa.entity.Position;
import cn.oa.service.PositionService;
import cn.oa.util.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.sql.SQLException;
import java.util.List;

public class PositionServiceImpl implements PositionService {
    SqlSession sqlSession = MyBatisUtil.createSqlSession();
    PositionDao positionDao = sqlSession.getMapper(PositionDao.class);

    @Override
    public List<Position> getAllPositions() throws SQLException {
        try{
            return positionDao.getAllPositions();
        }catch(SQLException e){
            e.printStackTrace();
            throw e;
        }finally{
           MyBatisUtil.closeSqlSession(sqlSession);
        }
    }
}
